import request from '@/utils/request'
import type {TreeMenuResponse, MenuItem, BaseResponse} from '@/types'

// 获取树形菜单数据（获取所有菜单，不需要分页）
export const getTreeMenuAPI = (): Promise<TreeMenuResponse> => {
  return request.get('/api/SysMenu/GetTreeList')
}

// 添加菜单
export const addMenuAPI = (data: MenuItem): Promise<BaseResponse> => {
  return request.post('/api/SysMenu/Insert', data)
}

// 修改菜单
export const updateMenuAPI = (data: MenuItem): Promise<BaseResponse> => {
  return request.post('/api/SysMenu/Update', data)
}

// 删除菜单
export const deleteMenuAPI = (id: string): Promise<BaseResponse> => {
  return request.post('/api/SysMenu/DelteByIds', [id])
}

